package com.yf.zzmusic.service.impl;

import com.yf.zzmusic.common.Constants;
import com.yf.zzmusic.exception.ServiceException;
import com.yf.zzmusic.pojo.dto.slide.SlideUpdateDTO;
import com.yf.zzmusic.pojo.entity.Slide;
import com.yf.zzmusic.mapper.SlideMapper;
import com.yf.zzmusic.service.ISlideService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 轮播图 服务实现类
 * </p>
 *
 * @author
 * @since 2024-02-28
 */
@Service
public class SlideServiceImpl extends ServiceImpl<SlideMapper, Slide> implements ISlideService {
  @Override
  public boolean updateSlide(SlideUpdateDTO slideUpdateDTO) {
    if (getById(slideUpdateDTO.getSlideId())==null){
      throw new ServiceException(Constants.NO_CONTENT,"轮播图未找到");
    }
    Slide slide=new Slide();
    //拷贝
    BeanUtils.copyProperties(slideUpdateDTO,slide);
    return updateById(slide);
  }
}
